package com.du;

import com.du.aop.MathCalculator;
import com.du.bean.Boss;
import com.du.bean.Car;
import com.du.bean.Color;
import com.du.config.MainConfigAutowired;
import com.du.config.MainConfigOfAOP;
import com.du.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author djg
 * @date 2020/11/23
 * @des
 */
public class IOCTestAOP {

    @Test
    public void test01() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfigOfAOP.class);
        //1、不要自己创建对象,要使用Spring容器中的对象
//        MathCalculator mathCalculator = new MathCalculator();
//        mathCalculator.div(1, 1);

        MathCalculator mathCalculator = applicationContext.getBean(MathCalculator.class);

        mathCalculator.div(1, 0);

        applicationContext.close();

    }
}
